package com.jisu.controller;


import com.jisu.common.ResultVo;
import com.jisu.pojo.ModelType;
import com.jisu.service.ModelTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RefreshScope
public class ModelTypeController {
    @Autowired
    private ModelTypeService modelTypeService;

    @GetMapping("/searchModelTypeById")
    public ResultVo<List<ModelType>> searchModelTypeByIds(@RequestParam List<Integer> modelTypeIds){
        try{
            List<ModelType> modelType = modelTypeService.listByIds(modelTypeIds);
            return ResultVo.success("查询成功", modelType);
        }catch (Exception e){
            e.printStackTrace();
            return ResultVo.fail("查询失败", e);
        }
    }

    @GetMapping("/getAllModelType")
    public ResultVo getAllModelType(){
        try{
            List<ModelType> modelTypes = modelTypeService.list();
            return ResultVo.success("查询成功", modelTypes);
        }catch (Exception e){
            e.printStackTrace();
            return ResultVo.fail("查询失败", e);
        }

    }
}
